home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / dskut / steprat1.zip / STEPRATE.ASM < prev    next >
Assembly Source File  |  1987-02-20  |  7KB  |  200 lines

  1. page     60,80
  2.  
  3. title    STEPRATE  A program to change the step rate of Floppy drives
  4. ;
  5. ; Before I receive any flames on the goodness of the following code, I
  6. ; would like to say that I find the 8088 destruction set disgusting.  I
  7. ; would have written this program in C (or some language which shelters
  8. ; me from the architecture but I have an inherent abhorance of 32K programs
  9. ; which do something as simple as this.
  10. ; If you do not like the way I wrote it, the feel free to rewrite it.
  11. ; In case you have not guessed, DEMENTed REGISTERS and I do not get along
  12. ; together.
  13.  
  14. .radix   16
  15.  
  16. ;***** Equates *********************************************************
  17.  
  18. cr       equ      0Dh      ;carriage return character
  19. lf       equ      0Ah      ;line feed character
  20.  
  21. ;********************************************
  22. datarea  segment
  23.          org      80h
  24. count    db       ?
  25. buffr    db       20d  dup (?)      ;input for step rate
  26. sm       db       'Floppy Drive Step Rate is set to $'
  27. m12      db       '12$'
  28. m8       db       '9$'
  29. m6       db       '6$'
  30. m3       db       '3$'
  31. mu       db       'UNKNOWN$'
  32. rms      db       ' ms.',cr,lf,'$'
  33. minval   db       '3, 6, 9 or 12 are the only recognized step rates.'
  34.          db       cr,lf,'$'
  35. datarea  ends
  36.  
  37.  
  38. ;***** Main Program ****************************************************
  39.  
  40. code     segment
  41.          assume   cs:code, es:code, ds:datarea, ss:stk_seg
  42.  
  43. ; Start--- Set up the stack so that DOS will be able to find it's
  44. ; DS when we return.  Ain't it disgusting that we have to fool with
  45. ; such nonsense!
  46.  
  47. start    proc     far
  48.          push     ds       ;save old data segment
  49.          sub      ax,ax    ;put zero in ax
  50.          push     ax       ;save it on stack
  51.  
  52.  
  53. ; see if a step rate entered from the keyboard 
  54.  
  55.          mov      bx, offset count  ;get the number of characters entered
  56.          mov      ah,[bx]
  57.          mov      al,ah    ;keep count in ah
  58.          cmp      al,0     ;see if any input
  59.          jz       noinput
  60.          mov      dx,0     ;set number to 0
  61. loop:
  62.          inc      bx       ;point to character buffer
  63.          mov      al,[bx]
  64.          cmp      al,' '
  65.          jz       aloop    ;step past spaces
  66.          cmp      al,'0'
  67.          jc       noinput
  68.          cmp      al,'9'+1
  69.          jnc      noinput
  70.          sub      al,'0'
  71.          push     ax       ;I suppose that there is some instruction
  72.          mov      al,dl    ; to ADD HL in the 8088 set. But I'm not gonna
  73.          add      al,al    ; look it up, anyhow times 2
  74.          mov      ah,al    ;and save it
  75.          add      al,al    ;times 4
  76.          add      al,al    ;times 8
  77.          add      al,ah    ;+ 2 = 10
  78.          mov      dl,al
  79.          pop      ax
  80.          add      al,dl
  81.          mov      dl,al
  82. aloop:
  83.          sub      ah,1     ;see if we are out of characters yet
  84.          jnz      loop     ;if not, stay at it till we run out (or bomb out)
  85.          mov      al,dl
  86.          mov      dl,0e0h  ;set for 3 ms step rate
  87.          cmp      al,3
  88.          jz       valid
  89.          mov      dl,0d0h
  90.          cmp      al,6     ; try for 6
  91.          jz       valid
  92.          mov      dl,0c0h
  93.          cmp      al,9     ;or 9
  94.          jz       valid
  95.          mov      dl,0b0h
  96.          cmp      al,12d   ; mayhaps 12
  97.          jz       valid
  98.  
  99. ; If we get to this point, we don't know what they have entered.
  100. ; Therefore, bomb out.
  101. ; set data segment register to where the messages are (I think)
  102.  
  103.          mov      ax,datarea
  104.          mov      ds,ax
  105.  
  106.          mov      dx, offset minval
  107.          mov      ah,9
  108.          int      21h
  109.          ret
  110.  
  111. ; a valid number has been entered, change the step rate to it
  112.  
  113. valid:
  114.          push     ds       ; Save the data segment
  115.          mov      bx,78h   ;point to pointer for floppy drive tables
  116.          mov      ax,0
  117.          mov      ds,ax    ;set to segment 0
  118.          mov      ax,[bx]  ;get the pointer
  119.          mov      bx,ax    ;into the bx register
  120.          mov      al,[bx]  ;now get the present step rate
  121.          and      al,0fh   ;remove the old step rate
  122.          or       al,dl    ;put in the new step rate
  123.          mov      [bx],al  ;and put it back where it goes
  124.          mov      ah,0     ;now call on the BIOS to
  125.          int      13h      ;reload the set floppy disk controller
  126.          pop      ds       ; Reset the Data Segment
  127.  
  128. ; if we get to this point, we have either had no specified step rate
  129. ; or a new step rate has been successfully loaded.  Let's tell 'em
  130. ; what they got.
  131.  
  132. noinput:
  133.  
  134.          push     ds       ;save present data segment
  135.  
  136.          mov      bx,78h   ;point to pointer for floppy drive tables
  137.          mov      ax,0
  138.          mov      ds,ax    ;set to segment 0
  139.          mov      ax,[bx]  ;get the pointer
  140.          mov      bx,ax    ;into the bx register
  141.          mov      al,[bx]  ;now get the step rate
  142.          pop      ds
  143.          push     ax       ;save the step rate on the stack
  144.  
  145.          mov      ax,datarea        ;no comment
  146.          mov      ds,ax
  147.  
  148.          mov      dx, offset sm     ;print beginning of message
  149.          mov      ah,9
  150.          int      21h
  151.  
  152.          pop      ax       ;get the step rate back
  153.  
  154.          and      al,0f0h  ;just interested in the step rate
  155.  
  156.          cmp      al,0b0h
  157.          jnz      ms8
  158.          mov      dx, offset m12
  159.          jmp      pms
  160. ms8:
  161.          cmp      al,0c0h
  162.          jnz      ms6
  163.          mov      dx, offset m8
  164.          jmp      pms
  165. ms6:
  166.          cmp      al,0d0h
  167.          jnz      ms3
  168.          mov      dx, offset m6
  169.          jmp      pms
  170. ms3:
  171.          cmp      al,0e0h
  172.          jnz      msu
  173.          mov      dx, offset m3
  174.          jmp      pms
  175. msu:
  176.          mov      dx, offset mu
  177. pms:
  178.          mov      ah,9
  179.          int      21h       ;print step rate
  180.  
  181.          mov      dx, offset rms    ;then print rest of message
  182.          mov      ah,9
  183.          int      21h
  184.  
  185.          ret      ; back to DOS
  186.  
  187. start    endp
  188. code     ends
  189.          
  190. ;*********************************************
  191. stk_seg  segment stack
  192.          db       20 dup ('stack   ')
  193. stk_seg  ends
  194.  
  195.          end      start
  196.  
  197.  
  198.  
  199.  
  200.